﻿namespace ACCOUNTING.LVY.Business
{
    using ACCOUNTING;
    using Microsoft.VisualBasic;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Data;
    using System.Runtime.CompilerServices;
    using System.Runtime.InteropServices;
    using System.Windows.Forms;

    public class clsNhapKho
    {
        private double mDaNopThue = 0.0;
        private double mDaNopThueNK = 0.0;
        private double mDaThanhToan = 0.0;
        private double mDaThanhToanNT = 0.0;
        private string mDienGiai = "";
        private string mDienGiaiPhiNK = "";
        private string mDuLieu = "NB";
        private int mDuyet = 0;
        private int mGhiSo = 0;
        private int mHanNopThueNK = 0;
        private int mHanThanhToan = 0;
        private string mKhoa = "";
        private string mKhoaBoPhan = "";
        private string mKhoaDoiTuong = "";
        private string mKhoaDoiTuongPhiNK = "";
        private string mKhoaDonHang = "";
        private string mKhoaDonVi = "";
        private string mKhoaHangMucBaoCaoThue = "";
        private string mKhoaHopDong = "";
        private string mKhoaKhoanMuc = "";
        private string mKhoaLoaiHoaDon = "";
        private string mKhoaLoaiHoaDonNK = "";
        private string mKhoaLoaiNhap = "";
        private string mKhoaNhanVien = "";
        private string mKhoaNhanVienSua = "";
        private string mKhoaNhanVienTao = "";
        private string mKhoaSanPham = "";
        private string mKhoaTKCoPhiNK = "";
        private string mKhoaTKCoThueVAT = "";
        private string mKhoaTKNoThueVAT = "";
        private string mKhoaTKThanhToan = "";
        private string mKhoaTKThueNK = "";
        private string mKhoaTKThuePhiNK = "";
        private string mLoaiPhanBoThueNK = "";
        private string mLoaiTien = "";
        private string mLoaiTienPhiNK = "";
        private string mMaSoThue = "";
        private string mNgayChungTu = "";
        private string mNgayDonHang = "";
        private string mNgayHoaDon = "";
        private string mNgayHoaDonNK = "";
        private string mNgayHoaDonPhiNK = "";
        private string mNgayNopThueNK = "";
        private string mNgaySua = "";
        private string mNgayTao = "";
        private string mNgayThanhToan = "";
        private string mNgayToKhai = "";
        private string mNguoiGiao = "";
        private string mNguonNhap = "";
        private string mPhanBoPhiNK = "";
        private int mSend = 0;
        private string mSoChungTu = "";
        private string mSoDonHang = "";
        private string mSoHoaDon = "";
        private string mSoHoaDonNK = "";
        private string mSoHoaDonPhiNK = "";
        private string mSoHopDong = "";
        private string mSoSeri = "";
        private string mSoSeriPhiNK = "";
        private string mSoToKhai = "";
        private int mThueSuat = 0;
        private int mThueSuatPhiNK = 0;
        private double mTienChietKhau = 0.0;
        private double mTienChietKhauNT = 0.0;
        private double mTienHang = 0.0;
        private double mTienHangNT = 0.0;
        private double mTienPhi = 0.0;
        private double mTienPhiNhap = 0.0;
        private double mTienPhiNhapKhau = 0.0;
        private double mTienPhiNhapKhauNT = 0.0;
        private double mTienPhiNK = 0.0;
        private double mTienPhiNKNT = 0.0;
        private double mTienPhiNT = 0.0;
        private double mTienThueNhapKhau = 0.0;
        private double mTienThueNhapKhauNT = 0.0;
        private double mTienThuePhiNhap = 0.0;
        private double mTienThuePhiNK = 0.0;
        private double mTienThuePhiNKNT = 0.0;
        private double mTienThueVAT = 0.0;
        private double mTienThueVATNT = 0.0;
        private double mTyGia = 0.0;
        private double mTyGiaPhiNK = 0.0;

        public void ClearTemp(string pKeyTable)
        {
            string commandText = "DELETE FROM ST_NhapKhoChiTietTmp WHERE KhoaPhieuNhap = '" + pKeyTable.Trim() + "'";
            DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]);
            commandText = "DELETE FROM ST_NhapKhoChiTietDichVuTmp WHERE KhoaPhieuNhap = '" + pKeyTable.Trim() + "'";
            DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]);
        }

        public bool DelData(string pKhoa)
        {
            IDataParameter parameter = null;
            bool flag=false;
            string commandText = "";
            try
            {
                commandText = "DELETE FROM ST_NhapKho WHERE Khoa = '" + pKhoa.Trim() + "'";
                bool flag2 = DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[] { parameter }) > 0;
                flag = flag2;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public bool DeleteData(string strKhoa)
        {
            bool flag=false;
            IDataParameter[] commandParameters = new IDataParameter[4];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@Khoa", DbType.Int64, ParameterDirection.Input, strKhoa);
                commandParameters[1] = DBHelper.createParameter("@CheckAK", DbType.Double, ParameterDirection.Input, 1);
                commandParameters[2] = DBHelper.createParameter("@AmKho", DbType.Double, ParameterDirection.Output, 0);
                commandParameters[3] = DBHelper.createParameter("@pError", DbType.Double, ParameterDirection.Output, 0);
                int num = DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "ST_sp_NhapKhoDel", commandParameters);
                if (Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectNotEqual(commandParameters[2].Value, 0, false))
                {
                    if (Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectNotEqual(commandParameters[3].Value, 0, false))
                    {
                        LVYModule.ShowWarning(modGeneral.Tranlated("Nghiệp vụ kh\x00f4ng thể thực hiện được v\x00ec \x00e2m kho!", ""));
                    }
                    return false;
                }
                flag = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public double GetAllVATChiPhi(string strKhoa)
        {
            string commandText = " SELECT IsNull(SUM(TienThue),0) As TienThue FROM ST_ChiPhiMuaHang WHERE KhoaPhieuNhap = '" + strKhoa + "'";
            return Conversions.ToDouble(DBHelper.ExecuteScalar(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]));
        }

        public DataTable GetDataPrint(string strKhoa)
        {
            DataTable table;
            try
            {
                string commandText = " Select NK.SoChungTu, dbo.Char2Date(NK.NgayChungTu) as NgayChungTu,  DT.Ten" + modGeneral.H_LANGUAGE + " as HangCungCap, NK.NguoiGiao, NK.SoToKhai,  dbo.Char2Date(NK.NgayToKhai) as NgayToKhai,  NK.SoHoaDonNK, dbo.Char2Date(NK.NgayHoaDonNK) as NgayHoaDonNK,  NK.SoHoaDon, NK.SoSeri, dbo.Char2Date(NK.NgayHoaDon) as NgayHoaDon,  NK.DienGiai, HH.Ma as MaHangHoa, HH.Ten" + modGeneral.H_LANGUAGE + " as TenHangHoa,  DVT.Ten" + modGeneral.H_LANGUAGE + " as DonViTinh, Sum(CT.SoLuong) as SoLuong, CT.DonGia,  Sum(CT.TienHang) as TienHang, Sum(CT.TienThueNhapKhau) as TienThueNhapKhau,  CT.TyLeThue, Sum(CT.TienThue) as TienThue, CT.HeSo as QuyCach, CT.SoLoHang, dbo.Char2Date(CT.NgayHetHanDung) As HanSuDung  FROM ST_NhapKho NK left join DM_DoiTuong DT on NK.KhoaDoiTuong = DT.Khoa  Left join ST_NhapKhoChiTiet CT on NK.Khoa = CT.KhoaPhieuNhap  Left join DM_DonViTinh DVT on CT.KhoaDonViTinh = DVT.Khoa  Left join DM_HangHoa HH on CT.KhoaHangHoa = HH.Khoa  Where NK.Khoa = '" + strKhoa + "' Group by NK.SoChungTu, NK.SoChungTu, NK.NgayChungTu,  DT.Ten" + modGeneral.H_LANGUAGE + " , NK.NguoiGiao, NK.SoToKhai,  NK.NgayToKhai, NK.SoHoaDonNK, NK.NgayHoaDonNK,  NK.SoHoaDon, NK.SoSeri, NK.NgayHoaDon,  NK.DienGiai, HH.Ma, HH.Ten" + modGeneral.H_LANGUAGE + " ,  DVT.Ten" + modGeneral.H_LANGUAGE + " , CT.SoLuong, CT.DonGia, CT.TyLeThue,  CT.HeSo, CT.SoLoHang, CT.NgayHetHanDung ";
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable GetDataPrintBKNhapKhoCT(string strKhoaDonVi, string strTuNgay, string strDenNgay, string strKhoaDoiTuong, string NguonNhap)
        {
            DataTable table;
            string str2 = "";
            try
            {
                if (strKhoaDoiTuong.Trim() != "")
                {
                    str2 = " AND NK.KhoaDoiTuong = '" + strKhoaDoiTuong + "'";
                }
                string commandText = "select NK.SoChungTu, dbo.Char2Date(NK.NgayChungTu) as Ngay, NK.SoHoaDon, NK.SoToKhai,  NK.DienGiai, DT.Ten" + modGeneral.H_LANGUAGE + " as NhaCungCap, NK.TienHang as TienHangPN, NK.TienThueNhapKhau as TienThueNhapKhauPN,  NK.TienChietKhau as TienChietKhauPN, NK.TienThueVAT as TienThuePN,  HH.Ma as MaHang, HH.Ten" + modGeneral.H_LANGUAGE + " as TenHang, DVT.Ten" + modGeneral.H_LANGUAGE + " as DonViTinh, CT.SoLuong, CT.DonGia, CT.TienHang,  CT.TienChietKhau, CT.TienThueNhapKhau, CT.TienThue  FROM ST_NhapKho NK left join ST_NhapKhoChiTiet CT on NK.Khoa = CT.KhoaPhieuNhap  left join DM_HangHoa HH on CT.KhoaHangHoa = HH.Khoa  left join DM_DonViTinh DVT on CT.KhoaDonViTinh = DVT.Khoa  left join DM_DoiTuong DT on NK.KhoaDoiTuong = DT.Khoa  WHERE NK.NguonNhap = '" + NguonNhap + "' And (NK.NgayChungTu between '" + strTuNgay + "' and '" + strDenNgay + "' ) And NK.KhoaDonVi = '" + strKhoaDonVi.Trim() + "'" + str2 + " Order by NK.NgayChungTu ";
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable GetDataPrintBKNhapKhoTH(string strKhoaDonVi, string strTuNgay, string strDenNgay, string strKhoaDoiTuong, string NguonNhap)
        {
            DataTable table;
            string str2 = "";
            try
            {
                if (strKhoaDoiTuong.Trim() != "")
                {
                    str2 = " AND NK.KhoaDoiTuong = '" + strKhoaDoiTuong + "'";
                }
                string commandText = " SELECT NK.SoChungTu, dbo.Char2Date(NK.NgayChungTu) as Ngay, NK.SoHoaDon, dbo.Char2Date(NK.NgayHoaDon) as NgayHoaDon,  NK.DienGiai, DT.Ten" + modGeneral.H_LANGUAGE + " as NhaCungCap, NK.TienHang, NK.TienThueNhapKhau, NK.TienThueVAT as TienThue  FROM ST_NhapKho NK left join DM_DoiTuong DT on NK.KhoaDoiTuong = DT.Khoa  WHERE NK.NguonNhap = '" + NguonNhap + "' And (NK.NgayChungTu between '" + strTuNgay + "' and '" + strDenNgay + "' ) And NK.KhoaDonVi = '" + strKhoaDonVi.Trim() + "'" + str2 + " Order by NK.NgayChungTu ";
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable GetDataPrintDichVu(string strKhoa)
        {
            DataTable table;
            try
            {
                string commandText = " Select NK.SoChungTu, dbo.Char2Date(NK.NgayChungTu) as NgayChungTu,  DT.Ten" + modGeneral.H_LANGUAGE + " as HangCungCap, NK.NguoiGiao, NK.SoToKhai,  dbo.Char2Date(NK.NgayToKhai) as NgayToKhai,  NK.SoHoaDonNK, dbo.Char2Date(NK.NgayHoaDonNK) as NgayHoaDonNK,  NK.SoHoaDon, NK.SoSeri, dbo.Char2Date(NK.NgayHoaDon) as NgayHoaDon,  NK.DienGiai, '' MaHangHoa, CT.TenDichVu as TenHangHoa,  '' as DonViTinh, CT.SoLuong, CT.DonGiaNT as DonGia,  CT.TienBanNT as TienHang,  CT.TyLeThue, CT.TienThueNT as TienThue, 1 as QuyCach, '' As SoLoHang, '' As HanSuDung  FROM ST_NhapKho NK left join DM_DoiTuong DT on NK.KhoaDoiTuong = DT.Khoa  Left join ST_NhapKhoChiTietDichVu CT on NK.Khoa = CT.KhoaPhieuNhap  Where NK.Khoa = '" + strKhoa + "'";
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable GetDataPrintHangTraLai(string strKhoaDonVi, string strTuNgay, string strDenNgay, string strKhoaDoiTuong)
        {
            DataTable table;
            IDataParameter[] commandParameters = new IDataParameter[5];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@KhoaDonVi", DbType.Int64, ParameterDirection.Input, strKhoaDonVi);
                commandParameters[1] = DBHelper.createParameter("@TuNgay", DbType.Int64, ParameterDirection.Input, strTuNgay);
                commandParameters[2] = DBHelper.createParameter("@DenNgay", DbType.Int64, ParameterDirection.Input, strDenNgay);
                commandParameters[3] = DBHelper.createParameter("@KhoaDoiTuong", DbType.Int64, ParameterDirection.Input, strKhoaDoiTuong);
                commandParameters[4] = DBHelper.createParameter("@Language", DbType.Int64, ParameterDirection.Input, modGeneral.H_LANGUAGE);
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.StoredProcedure, "BC_sp_BangKeHangHoaTraLai", commandParameters).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable GetDataPrintHanNopThue(string strKhoaDonVi, string strTinhDenHan, string strSoNgay)
        {
            DataTable table;
            IDataParameter[] commandParameters = new IDataParameter[4];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@KhoaDonVi", DbType.Int64, ParameterDirection.Input, strKhoaDonVi);
                commandParameters[1] = DBHelper.createParameter("@TinhDenHan", DbType.Int64, ParameterDirection.Input, strTinhDenHan);
                commandParameters[2] = DBHelper.createParameter("@SoNgay", DbType.Int64, ParameterDirection.Input, strSoNgay);
                commandParameters[3] = DBHelper.createParameter("@Language", DbType.Int64, ParameterDirection.Input, modGeneral.H_LANGUAGE);
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.StoredProcedure, "BC_sp_BangKeThueNhapKhauDenHanNop", commandParameters).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable GetDataPrintHeHanDung(string strNgay, int nSoNgay, string strKhoaDonVi, string strKhoaKho = "")
        {
            DataTable table;
            IDataParameter[] commandParameters = new IDataParameter[5];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@Ngay", DbType.Int64, ParameterDirection.Input, strNgay);
                commandParameters[1] = DBHelper.createParameter("@SoNgay", DbType.Int64, ParameterDirection.Input, nSoNgay);
                commandParameters[2] = DBHelper.createParameter("@KhoaDonVi", DbType.Int64, ParameterDirection.Input, strKhoaDonVi);
                commandParameters[3] = DBHelper.createParameter("@KhoaKho", DbType.Int64, ParameterDirection.Input, strKhoaKho);
                commandParameters[4] = DBHelper.createParameter("@Language", DbType.Int64, ParameterDirection.Input, modGeneral.H_LANGUAGE);
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.StoredProcedure, "Get_HangHoaHetHanSuDung", commandParameters).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable GetDataPrintHoaDonThanhToan(string strKhoaDonVi, string strTuNgay, string strDenNgay, string strKhoaDoiTuong, string strNguonNhap, int pXemTatCa)
        {
            DataTable table;
            IDataParameter[] commandParameters = new IDataParameter[7];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@KhoaDonVi", DbType.Int64, ParameterDirection.Input, strKhoaDonVi);
                commandParameters[1] = DBHelper.createParameter("@TuNgay", DbType.Int64, ParameterDirection.Input, strTuNgay);
                commandParameters[2] = DBHelper.createParameter("@DenNgay", DbType.Int64, ParameterDirection.Input, strDenNgay);
                commandParameters[3] = DBHelper.createParameter("@KhoaBaoCao", DbType.Int64, ParameterDirection.Input, strKhoaDoiTuong);
                commandParameters[4] = DBHelper.createParameter("@NguonNhap", DbType.Int64, ParameterDirection.Input, strNguonNhap);
                commandParameters[5] = DBHelper.createParameter("@Language", DbType.Int64, ParameterDirection.Input, modGeneral.H_LANGUAGE);
                commandParameters[6] = DBHelper.createParameter("@XemTatCa", DbType.Int32, ParameterDirection.Input, pXemTatCa);
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.StoredProcedure, "MH_sp_GetHoaDonNoThanhToanNhaCungCap", commandParameters).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable GetDataPrintNhapKhau(string pKhoa)
        {
            DataTable table;
            IDataParameter[] commandParameters = new IDataParameter[2];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@Khoa", DbType.Int64, ParameterDirection.Input, pKhoa);
                commandParameters[1] = DBHelper.createParameter("@Language", DbType.Int64, ParameterDirection.Input, modGeneral.H_LANGUAGE);
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.StoredProcedure, "Get_PrintPhieuNhapKhau", commandParameters).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable GetDataPrintNhapXuatTonKho(string strTuNgay, string strDenNgay, string strKhoaDonVi, string strKhoaKho, string strKhoaNhom)
        {
            DataTable table;
            IDataParameter[] commandParameters = new IDataParameter[7];
            try
            {
                commandParameters[1] = DBHelper.createParameter("@TuNgay", DbType.Int64, ParameterDirection.Input, strTuNgay);
                commandParameters[2] = DBHelper.createParameter("@DenNgay", DbType.Int64, ParameterDirection.Input, strDenNgay);
                commandParameters[3] = DBHelper.createParameter("@Language", DbType.Int64, ParameterDirection.Input, modGeneral.H_LANGUAGE);
                commandParameters[4] = DBHelper.createParameter("@KhoaDonVi", DbType.Int64, ParameterDirection.Input, strKhoaDonVi);
                commandParameters[5] = DBHelper.createParameter("@KhoaKho", DbType.Int64, ParameterDirection.Input, strKhoaKho);
                commandParameters[6] = DBHelper.createParameter("@KhoaNhom", DbType.Int64, ParameterDirection.Input, strKhoaNhom);
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.StoredProcedure, "ST_BC_NhapXuatTon", commandParameters).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable GetDataPrintNhapXuatTonKhoTongHop(string strTuNgay, string strDenNgay, string strKhoaDonVi, string strKhoaNhom)
        {
            DataTable table;
            IDataParameter[] commandParameters = new IDataParameter[7];
            try
            {
                commandParameters[1] = DBHelper.createParameter("@KhoaDonVi", DbType.Int64, ParameterDirection.Input, strKhoaDonVi);
                commandParameters[2] = DBHelper.createParameter("@TuNgay", DbType.Int64, ParameterDirection.Input, strTuNgay);
                commandParameters[3] = DBHelper.createParameter("@DenNgay", DbType.Int64, ParameterDirection.Input, strDenNgay);
                commandParameters[4] = DBHelper.createParameter("@KhoaNhom", DbType.Int64, ParameterDirection.Input, strKhoaNhom);
                commandParameters[5] = DBHelper.createParameter("@Language", DbType.Int64, ParameterDirection.Input, modGeneral.H_LANGUAGE);
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.StoredProcedure, "ST_BC_NhapXuatTonTheoHangHoa", commandParameters).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable GetDataPrintTonDuoiDinhMuc(string strKhoaDonVi, string strKhoaHangHoa, string strKhoaKho, string strNamThang)
        {
            DataTable table;
            IDataParameter[] commandParameters = new IDataParameter[5];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@KhoaDonVi", DbType.Int64, ParameterDirection.Input, strKhoaDonVi);
                commandParameters[1] = DBHelper.createParameter("@KhoaNhomHangHoa", DbType.Int64, ParameterDirection.Input, strKhoaHangHoa);
                commandParameters[2] = DBHelper.createParameter("@KhoaKho", DbType.Int64, ParameterDirection.Input, strKhoaKho);
                commandParameters[3] = DBHelper.createParameter("@NamThang", DbType.Int64, ParameterDirection.Input, strNamThang);
                commandParameters[4] = DBHelper.createParameter("@Language", DbType.Int64, ParameterDirection.Input, modGeneral.H_LANGUAGE);
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.StoredProcedure, "BC_sp_BangKeTonDuoiDinhMuc", commandParameters).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable GetDataPrintTonKhoDauKy(string strKhoaDonVi, string strKhoaHangHoa, string strKhoaKho, string strNamThang)
        {
            DataTable table;
            IDataParameter[] commandParameters = new IDataParameter[5];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@KhoaDonVi", DbType.Int64, ParameterDirection.Input, strKhoaDonVi);
                commandParameters[1] = DBHelper.createParameter("@KhoaHangHoa", DbType.Int64, ParameterDirection.Input, strKhoaHangHoa);
                commandParameters[2] = DBHelper.createParameter("@KhoaKho", DbType.Int64, ParameterDirection.Input, strKhoaKho);
                commandParameters[3] = DBHelper.createParameter("@NamThang", DbType.Int64, ParameterDirection.Input, strNamThang);
                commandParameters[4] = DBHelper.createParameter("@Language", DbType.Int64, ParameterDirection.Input, modGeneral.H_LANGUAGE);
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.StoredProcedure, "BC_sp_BangKeTonKhoDauKy", commandParameters).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable GetDataPrintTraHangNhaCungCap(string strKhoaDonVi, string strTuNgay, string strDenNgay, string strKhoaDoiTuong)
        {
            DataTable table;
            IDataParameter[] commandParameters = new IDataParameter[5];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@KhoaDonVi", DbType.Int64, ParameterDirection.Input, strKhoaDonVi);
                commandParameters[1] = DBHelper.createParameter("@TuNgay", DbType.Int64, ParameterDirection.Input, strTuNgay);
                commandParameters[2] = DBHelper.createParameter("@DenNgay", DbType.Int64, ParameterDirection.Input, strDenNgay);
                commandParameters[3] = DBHelper.createParameter("@KhoaDoiTuong", DbType.Int64, ParameterDirection.Input, strKhoaDoiTuong);
                commandParameters[4] = DBHelper.createParameter("@Language", DbType.Int64, ParameterDirection.Input, modGeneral.H_LANGUAGE);
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.StoredProcedure, "BC_sp_BangKeHangHoaTraLai", commandParameters).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable GetDataTongHopThanhToanTienHang(string strKhoaDonVi, int strTuNgay, string strDenNgay, string strKhoaDoiTuong = "")
        {
            DataTable table;
            IDataParameter[] commandParameters = new IDataParameter[4];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@KhoaDonVi", DbType.Int64, ParameterDirection.Input, strKhoaDonVi);
                commandParameters[1] = DBHelper.createParameter("@TuNgay", DbType.Int64, ParameterDirection.Input, strTuNgay);
                commandParameters[2] = DBHelper.createParameter("@DenNgay", DbType.Int64, ParameterDirection.Input, strDenNgay);
                commandParameters[3] = DBHelper.createParameter("@KhoaDoiTuong", DbType.Int64, ParameterDirection.Input, strKhoaDoiTuong);
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.StoredProcedure, "ST_sp_TongHopThanhToanTienHang", commandParameters).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable GetDetailDichVu(string strKhoa)
        {
            DataTable table;
            try
            {
                string commandText = " SELECT CT.Khoa, CT.KhoaTKChiPhi As KhoaTaiKhoan, TK.SoTaiKhoan, CT.TenDichVu, CT.MaDichVu, CT.KhoaDichVu, CT.SoLuong,  CT.DonGiaNT, CT.TienBanNT, CT.TyLeChietKhau, CT.TienChietKhauNT, CT.TyLeThue, CT.TienThueNT, CT.KhoaDoiTuongTapHopChiPhi,CT.TenDoiTuongTapHopChiPhi FROM  ST_NhapKhoChiTietDichVu CT LEFT JOIN DM_TaiKhoan TK ON CT.KhoaTKChiPhi = TK.Khoa  WHERE CT.KhoaPhieuNhap = '" + strKhoa + "'";
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable GetDetailsTraHang(string strKhoa)
        {
            DataTable table;
            try
            {
                string commandText = " SELECT CT.Khoa, CT.KhoaKho, K.Ten" + modGeneral.H_LANGUAGE + " as KhoHang, CT.KhoaHangHoa, HH.Ma, HH.Ten" + modGeneral.H_LANGUAGE + " as HangHoa,  CT.SoLoHang, CT.SoSeri, CT.NgayNhap, CT.NgayHetHanDung as HanSuDung, CT.KhoaDonViTinh, DVT.Ten" + modGeneral.H_LANGUAGE + " as DonViTinh, CT.HeSo as QuyCach, CT.SoLuong, CT.DonGiaNT, CT.TienHangNT, CT.TyLeChietKhau,  CT.TienChietKhauNT, CT.TyLeThue, CT.TienThueNT,  CT.TyLeThueNK, CT.TienThueNhapKhauNT, CT.KhoaTKHangHoa, TK.SoTaiKhoan as TaiKhoanHangHoa,  CT.KhoaTKGiaVon, GV.SoTaiKhoan as TaiKhoanGiaVon, CT.GiaBanNT, CT.TienBanNT  FROM ST_NhapKhoChiTiet CT LEFT JOIN DM_Kho K on CT.KhoaKho = K.Khoa  LEFT JOIN DM_HangHoa HH on CT.KhoaHangHoa = HH.Khoa  LEFT JOIN DM_DonViTinh DVT on CT.KhoaDonViTinh = DVT.Khoa  LEFT JOIN DM_TaiKhoan TK on CT.KhoaTKHangHoa = TK.Khoa  LEFT JOIN DM_TaiKhoan GV on CT.KhoaTKGiaVon = GV.Khoa  WHERE CT.KhoaPhieuNhap = '" + strKhoa + "'";
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public double GetGiaVon(string pKhoaKho, string pKhoaHangHoa, string pLoai, string pNgay)
        {
            string str;
            if (pLoai == "GM")
            {
                str = "SELECT GiaMua FROM MH_GiaMua WHERE KhoaHangHoa = '" + pKhoaHangHoa + "' and LoaiTien = '" + modGeneral.H_CURRENCY.Trim() + "'";
            }
            else
            {
                str = " SELECT avg(DonGia) as GiaMua FROM ST_TonKhoDauKy WHERE KhoaHangHoa = '" + pKhoaHangHoa + "' and NamThang = '" + LVYModule.sLeft(pNgay, 6) + "'";
            }
            return Conversions.ToDouble(LVYModule.ReturnIfNull(RuntimeHelpers.GetObjectValue(DBHelper.ExecuteScalar(modGeneral.ConnectionString, CommandType.Text, str, new IDataParameter[0])), 0, modGeneral.TypeOfValue.Nothing));
        }

        public DataTable GetList(string strCondition = "")
        {
            DataTable table;
            string str2 = "";
            try
            {
                if (strCondition.Trim() != "")
                {
                    str2 = " WHERE " + strCondition;
                }
                string commandText = "SELECT NK.Khoa, NK.SoChungTu, dbo.Char2Date(NK.NgayChungTu) as Ngay, NK.SoHoaDon, DT.Ten" + modGeneral.H_LANGUAGE + " as NhaCungCap,  NK.TienHangNT - NK.TienChietKhauNT + NK.TienThueVATNT + NK.TienThueNhapKhauNT as SoTienNT,  NK.TienHang - NK.TienChietKhau + NK.TienThueVAT + NK.TienThueNhapKhau as SoTien, NK.DienGiai,NK.GhiSo FROM ST_NhapKho NK LEFT JOIN DM_DoiTuong DT ON NK.KhoaDoiTuong = DT.Khoa " + str2 + " ORDER BY NK.NgayChungTu, NK.SoChungTu ";
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable GetListDetails(string strKhoa)
        {
            DataTable table;
            try
            {
                string commandText = " SELECT CT.Khoa, CT.KhoaKho, K.Ma as KhoHang, CT.KhoaHangHoa, HH.Ma, HH.Ten" + modGeneral.H_LANGUAGE + " as HangHoa,  CT.SoLoHang, CT.SoSeri, CT.NgayNhap, CT.NgayHetHanDung, CT.KhoaDonViTinh, DVT.Ten" + modGeneral.H_LANGUAGE + " as DonViTinh, CT.HeSo, CT.SoLuong, CT.DonGiaNT,CT.GiaBanNT, CT.TienHangNT, CT.TienHang, CT.TyLeChietKhau,  CT.TienChietKhauNT, CT.TienPhiNhapKhauNT, CT.TienPhiNhapKhau, CT.TyLeThue, CT.TienThueNT,  CT.TyLeThueNK, CT.TienThueNhapKhauNT, CT.TienThueNhapKhau, CT.KhoaTKHangHoa, TK.SoTaiKhoan,  CT.TienPhiNKNT, CT.TienPhiNK, CT.DonGia FROM ST_NhapKhoChiTiet CT LEFT JOIN DM_Kho K on CT.KhoaKho = K.Khoa  LEFT JOIN DM_HangHoa HH on CT.KhoaHangHoa = HH.Khoa  LEFT JOIN DM_DonViTinh DVT on CT.KhoaDonViTinh = DVT.Khoa  LEFT JOIN DM_TaiKhoan TK on CT.KhoaTKHangHoa = TK.Khoa  WHERE CT.KhoaPhieuNhap = '" + strKhoa + "'";
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable GetListDetailsTH(string strKhoa, int intTLThue)
        {
            DataTable table;
            try
            {
                string commandText = " SELECT CT.Khoa, CT.KhoaKho, K.Ma as KhoHang, CT.KhoaHangHoa, HH.Ma, HH.Ten" + modGeneral.H_LANGUAGE + " as HangHoa,  CT.SoLoHang, CT.SoSeri, CT.NgayNhap, CT.NgayHetHanDung, CT.KhoaDonViTinh, DVT.Ten" + modGeneral.H_LANGUAGE + " as DonViTinh, CT.HeSo, CT.SoLuong, CT.SoLuongDaTra, CT.DonGiaNT,CT.GiaBanNT, CT.TienHangNT, CT.TienHang, CT.TyLeChietKhau,  CT.TienChietKhauNT, CT.TienPhiNhapKhauNT, CT.TienPhiNhapKhau, CT.TyLeThue, CT.TienThueNT,  CT.TyLeThueNK, CT.TienThueNhapKhauNT, CT.TienThueNhapKhau, CT.KhoaTKHangHoa, TK.SoTaiKhoan,  CT.TienPhiNKNT, CT.TienPhiNK  FROM ST_NhapKhoChiTiet CT LEFT JOIN DM_Kho K on CT.KhoaKho = K.Khoa  LEFT JOIN DM_HangHoa HH on CT.KhoaHangHoa = HH.Khoa  LEFT JOIN DM_DonViTinh DVT on CT.KhoaDonViTinh = DVT.Khoa  LEFT JOIN DM_TaiKhoan TK on CT.KhoaTKHangHoa = TK.Khoa  WHERE CT.KhoaPhieuNhap = '" + strKhoa + "' AND CT.TyLeThue = " + Conversions.ToString(intTLThue) + " AND CT.SoLuong - CT.SoLuongDaTra > 0";
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable GetListDropDown(string strKhoaPhieuXuat)
        {
            DataTable table;
            try
            {
                string commandText = "SELECT HH.Khoa, HH.SoChungTu, dbo.Char2Date(HH.NgayChungTu) as NgayChungTu,  DT.Ten" + modGeneral.H_LANGUAGE + " as DoiTuong, HH.SoTienHoaHongNT  FROM ST_HoaHong HH left join DM_DoiTuong DT on HH.KhoaDoiTuong = DT.Khoa  WHERE HH.KhoaPhieuXuat = '" + strKhoaPhieuXuat + "'";
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public void GetSoTaiKhoan(string strKhoa, ref string strTKNo, ref string strTKCo)
        {
            string commandText = "";
            clsDMTaiKhoan khoan = new clsDMTaiKhoan();
            int num = 0;
            try
            {
                strTKNo = "";
                strTKCo = "";
                this.Load(strKhoa);
                if (this.mTienThueVAT != 0.0)
                {
                    khoan.Load(LVYModule.ReturnIfNull(this.mKhoaTKNoThueVAT, "", modGeneral.TypeOfValue.Nothing).ToString().Trim());
                    strTKNo = LVYModule.ReturnIfNull(khoan.SoTaiKhoan, "", modGeneral.TypeOfValue.Nothing).ToString().Trim();
                }
                commandText = "SELECT Distinct(SoTaiKhoan) SoTaiKhoan FROM DM_TaiKhoan Where Khoa in (Select KhoaTKHangHoa  FROM ST_NhapKhoChiTiet Where KhoaPhieuNhap = '" + strKhoa + "')";
                DataTable table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
                if (table != null)
                {
                    int num2 = table.Rows.Count - 1;
                    for (num = 0; num <= num2; num++)
                    {
                        if (strTKNo.Trim() == "")
                        {
                            strTKNo = table.Rows[num]["SoTaiKhoan"].ToString().Trim();
                        }
                        else
                        {
                            strTKNo = strTKNo + "," + table.Rows[num]["SoTaiKhoan"].ToString().Trim();
                        }
                    }
                    commandText = "SELECT Distinct(SoTaiKhoan) SoTaiKhoan FROM DM_TaiKhoan Where Khoa in (Select KhoaTKChiPhi  FROM ST_NhapKhoChiTietDichVu Where KhoaPhieuNhap = '" + strKhoa + "')";
                    table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
                    if (table != null)
                    {
                        int num3 = table.Rows.Count - 1;
                        for (num = 0; num <= num3; num++)
                        {
                            if (strTKNo.Trim() == "")
                            {
                                strTKNo = table.Rows[num]["SoTaiKhoan"].ToString().Trim();
                            }
                            else
                            {
                                strTKNo = strTKNo + "," + table.Rows[num]["SoTaiKhoan"].ToString().Trim();
                            }
                        }
                        khoan.Load(LVYModule.ReturnIfNull(this.mKhoaTKThanhToan, "", modGeneral.TypeOfValue.Nothing).ToString().Trim());
                        strTKCo = khoan.SoTaiKhoan.Trim();
                    }
                }
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                strTKNo = "";
                strTKCo = "";
                ProjectData.ClearProjectError();
            }
        }

        public bool IsDuplicateVoucherNo(string strVoucherNo, string strKeyTable)
        {
            string commandText = "SELECT * FROM ST_NhapKho Where Rtrim(SoChungTu) = '" + strVoucherNo.Trim() + "' AND Khoa <> '" + strKeyTable + "'";
            return (DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0].Rows.Count > 0);
        }

        public bool Load(string pKhoa)
        {
            bool flag=false;
            try
            {
                string commandText = "SELECT * FROM ST_NhapKho WHERE Khoa = '" + pKhoa + "'";
                IDataReader dataReader = DBHelper.ExecuteReader(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]);
                if (dataReader.Read())
                {
                    this.mKhoa = Conversions.ToString(modGeneral.GetValue(dataReader, 0, modGeneral.typeOfColumn.GetString));
                    this.mKhoaLoaiNhap = Conversions.ToString(modGeneral.GetValue(dataReader, 1, modGeneral.typeOfColumn.GetString));
                    this.mKhoaKhoanMuc = Conversions.ToString(modGeneral.GetValue(dataReader, 2, modGeneral.typeOfColumn.GetString));
                    this.mKhoaDonHang = Conversions.ToString(modGeneral.GetValue(dataReader, 3, modGeneral.typeOfColumn.GetString));
                    this.mSoDonHang = Conversions.ToString(modGeneral.GetValue(dataReader, 4, modGeneral.typeOfColumn.GetString));
                    this.mNgayDonHang = Conversions.ToString(modGeneral.GetValue(dataReader, 5, modGeneral.typeOfColumn.GetString));
                    this.mSoChungTu = Conversions.ToString(modGeneral.GetValue(dataReader, 6, modGeneral.typeOfColumn.GetString));
                    this.mNgayChungTu = Conversions.ToString(modGeneral.GetValue(dataReader, 7, modGeneral.typeOfColumn.GetString));
                    this.mKhoaDoiTuong = Conversions.ToString(modGeneral.GetValue(dataReader, 8, modGeneral.typeOfColumn.GetString));
                    this.mKhoaNhanVien = Conversions.ToString(modGeneral.GetValue(dataReader, 9, modGeneral.typeOfColumn.GetString));
                    this.mNguoiGiao = Conversions.ToString(modGeneral.GetValue(dataReader, 10, modGeneral.typeOfColumn.GetString));
                    this.mLoaiTien = Conversions.ToString(modGeneral.GetValue(dataReader, 11, modGeneral.typeOfColumn.GetString));
                    this.mTyGia = Conversions.ToDouble(modGeneral.GetValue(dataReader, 12, modGeneral.typeOfColumn.GetDecimal));
                    this.mMaSoThue = Conversions.ToString(modGeneral.GetValue(dataReader, 13, modGeneral.typeOfColumn.GetString));
                    this.mKhoaLoaiHoaDon = Conversions.ToString(modGeneral.GetValue(dataReader, 14, modGeneral.typeOfColumn.GetString));
                    this.mThueSuat = Conversions.ToInteger(modGeneral.GetValue(dataReader, 15, modGeneral.typeOfColumn.GetInt32));
                    this.mSoHoaDon = Conversions.ToString(modGeneral.GetValue(dataReader, 0x10, modGeneral.typeOfColumn.GetString));
                    this.mNgayHoaDon = Conversions.ToString(modGeneral.GetValue(dataReader, 0x11, modGeneral.typeOfColumn.GetString));
                    this.mSoSeri = Conversions.ToString(modGeneral.GetValue(dataReader, 0x12, modGeneral.typeOfColumn.GetString));
                    this.mSoToKhai = Conversions.ToString(modGeneral.GetValue(dataReader, 0x13, modGeneral.typeOfColumn.GetString));
                    this.mNgayToKhai = Conversions.ToString(modGeneral.GetValue(dataReader, 20, modGeneral.typeOfColumn.GetString));
                    this.mSoHoaDonNK = Conversions.ToString(modGeneral.GetValue(dataReader, 0x15, modGeneral.typeOfColumn.GetString));
                    this.mNgayHoaDonNK = Conversions.ToString(modGeneral.GetValue(dataReader, 0x16, modGeneral.typeOfColumn.GetString));
                    this.mHanNopThueNK = Conversions.ToInteger(modGeneral.GetValue(dataReader, 0x17, modGeneral.typeOfColumn.GetInt32));
                    this.mNgayNopThueNK = Conversions.ToString(modGeneral.GetValue(dataReader, 0x18, modGeneral.typeOfColumn.GetString));
                    this.mLoaiPhanBoThueNK = Conversions.ToString(modGeneral.GetValue(dataReader, 0x19, modGeneral.typeOfColumn.GetString));
                    this.mTienHangNT = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x1a, modGeneral.typeOfColumn.GetDecimal));
                    this.mTienHang = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x1b, modGeneral.typeOfColumn.GetDecimal));
                    this.mTienChietKhauNT = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x1c, modGeneral.typeOfColumn.GetDecimal));
                    this.mTienChietKhau = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x1d, modGeneral.typeOfColumn.GetDecimal));
                    this.mTienPhiNhapKhauNT = Conversions.ToDouble(modGeneral.GetValue(dataReader, 30, modGeneral.typeOfColumn.GetDecimal));
                    this.mTienPhiNhapKhau = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x1f, modGeneral.typeOfColumn.GetDecimal));
                    this.mTienThueNhapKhauNT = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x20, modGeneral.typeOfColumn.GetDecimal));
                    this.mTienThueNhapKhau = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x21, modGeneral.typeOfColumn.GetDecimal));
                    this.mTienThueVATNT = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x22, modGeneral.typeOfColumn.GetDecimal));
                    this.mTienThueVAT = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x23, modGeneral.typeOfColumn.GetDecimal));
                    this.mTienPhiNT = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x24, modGeneral.typeOfColumn.GetDecimal));
                    this.mTienPhi = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x25, modGeneral.typeOfColumn.GetDecimal));
                    this.mKhoaTKThanhToan = Conversions.ToString(modGeneral.GetValue(dataReader, 0x26, modGeneral.typeOfColumn.GetString));
                    this.mKhoaTKThueNK = Conversions.ToString(modGeneral.GetValue(dataReader, 0x27, modGeneral.typeOfColumn.GetString));
                    this.mKhoaTKNoThueVAT = Conversions.ToString(modGeneral.GetValue(dataReader, 40, modGeneral.typeOfColumn.GetString));
                    this.mKhoaTKCoThueVAT = Conversions.ToString(modGeneral.GetValue(dataReader, 0x29, modGeneral.typeOfColumn.GetString));
                    this.mNguonNhap = Conversions.ToString(modGeneral.GetValue(dataReader, 0x2a, modGeneral.typeOfColumn.GetString));
                    this.mDienGiai = Conversions.ToString(modGeneral.GetValue(dataReader, 0x2b, modGeneral.typeOfColumn.GetString));
                    this.mHanThanhToan = Conversions.ToInteger(modGeneral.GetValue(dataReader, 0x2c, modGeneral.typeOfColumn.GetInt32));
                    this.mNgayThanhToan = Conversions.ToString(modGeneral.GetValue(dataReader, 0x2d, modGeneral.typeOfColumn.GetString));
                    this.mDaThanhToanNT = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x2e, modGeneral.typeOfColumn.GetDecimal));
                    this.mDaThanhToan = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x2f, modGeneral.typeOfColumn.GetDecimal));
                    this.mKhoaNhanVienTao = Conversions.ToString(modGeneral.GetValue(dataReader, 0x30, modGeneral.typeOfColumn.GetString));
                    this.mNgayTao = Conversions.ToString(modGeneral.GetValue(dataReader, 0x31, modGeneral.typeOfColumn.GetString));
                    this.mKhoaNhanVienSua = Conversions.ToString(modGeneral.GetValue(dataReader, 50, modGeneral.typeOfColumn.GetString));
                    this.mNgaySua = Conversions.ToString(modGeneral.GetValue(dataReader, 0x33, modGeneral.typeOfColumn.GetString));
                    this.mGhiSo = Conversions.ToInteger(modGeneral.GetValue(dataReader, 0x34, modGeneral.typeOfColumn.GetInt32));
                    this.mKhoaDonVi = Conversions.ToString(modGeneral.GetValue(dataReader, 0x35, modGeneral.typeOfColumn.GetString));
                    this.mSend = Conversions.ToInteger(modGeneral.GetValue(dataReader, 0x36, modGeneral.typeOfColumn.GetInt32));
                    this.mKhoaBoPhan = Conversions.ToString(modGeneral.GetValue(dataReader, 0x37, modGeneral.typeOfColumn.GetString));
                    this.mKhoaSanPham = Conversions.ToString(modGeneral.GetValue(dataReader, 0x38, modGeneral.typeOfColumn.GetString));
                    this.mKhoaHopDong = Conversions.ToString(modGeneral.GetValue(dataReader, 0x39, modGeneral.typeOfColumn.GetString));
                    this.mSoHopDong = Conversions.ToString(modGeneral.GetValue(dataReader, 0x3a, modGeneral.typeOfColumn.GetString));
                    this.mDaNopThueNK = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x3b, modGeneral.typeOfColumn.GetDecimal));
                    this.mDaNopThue = Conversions.ToDouble(modGeneral.GetValue(dataReader, 60, modGeneral.typeOfColumn.GetDecimal));
                    this.mTienPhiNhap = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x3d, modGeneral.typeOfColumn.GetDecimal));
                    this.mTienThuePhiNhap = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x3e, modGeneral.typeOfColumn.GetDecimal));
                    this.mKhoaTKCoPhiNK = Conversions.ToString(modGeneral.GetValue(dataReader, 0x3f, modGeneral.typeOfColumn.GetString));
                    this.mKhoaTKThuePhiNK = Conversions.ToString(modGeneral.GetValue(dataReader, 0x40, modGeneral.typeOfColumn.GetString));
                    this.mKhoaDoiTuongPhiNK = Conversions.ToString(modGeneral.GetValue(dataReader, 0x41, modGeneral.typeOfColumn.GetString));
                    this.mLoaiTienPhiNK = Conversions.ToString(modGeneral.GetValue(dataReader, 0x42, modGeneral.typeOfColumn.GetString));
                    this.mTyGiaPhiNK = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x43, modGeneral.typeOfColumn.GetDecimal));
                    this.mPhanBoPhiNK = Conversions.ToString(modGeneral.GetValue(dataReader, 0x44, modGeneral.typeOfColumn.GetString));
                    this.mKhoaLoaiHoaDonNK = Conversions.ToString(modGeneral.GetValue(dataReader, 0x45, modGeneral.typeOfColumn.GetString));
                    this.mSoHoaDonPhiNK = Conversions.ToString(modGeneral.GetValue(dataReader, 70, modGeneral.typeOfColumn.GetString));
                    this.mNgayHoaDonPhiNK = Conversions.ToString(modGeneral.GetValue(dataReader, 0x47, modGeneral.typeOfColumn.GetString));
                    this.mSoSeriPhiNK = Conversions.ToString(modGeneral.GetValue(dataReader, 0x48, modGeneral.typeOfColumn.GetString));
                    this.mThueSuatPhiNK = Conversions.ToInteger(modGeneral.GetValue(dataReader, 0x49, modGeneral.typeOfColumn.GetInt32));
                    this.mTienPhiNKNT = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x4a, modGeneral.typeOfColumn.GetDecimal));
                    this.mTienPhiNK = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x4b, modGeneral.typeOfColumn.GetDecimal));
                    this.mTienThuePhiNKNT = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x4c, modGeneral.typeOfColumn.GetDecimal));
                    this.mTienThuePhiNK = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x4d, modGeneral.typeOfColumn.GetDecimal));
                    this.mDienGiaiPhiNK = Conversions.ToString(modGeneral.GetValue(dataReader, 0x4e, modGeneral.typeOfColumn.GetString));
                    this.mDuLieu = Conversions.ToString(modGeneral.GetValue(dataReader, 0x4f, modGeneral.typeOfColumn.GetString));
                    this.mDuyet = Conversions.ToInteger(modGeneral.GetValue(dataReader, 80, modGeneral.typeOfColumn.GetInt32));
                    this.mKhoaHangMucBaoCaoThue = Conversions.ToString(modGeneral.GetValue(dataReader, 0x51, modGeneral.typeOfColumn.GetString));
                }
                dataReader.Close();
                flag = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public bool Registered(string strKhoa, string strKhoaTKThanhToan, string strKhoaTKThueNK, string strKhoaTKNoThueVAT, string strKhoaTKCoThueVAT)
        {
            bool flag=false;
            IDataParameter[] commandParameters = new IDataParameter[8];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@KhoaPhieuNhap", DbType.Int64, ParameterDirection.Input, strKhoa);
                commandParameters[1] = DBHelper.createParameter("@KhoaTKThanhToan", DbType.Int64, ParameterDirection.Input, strKhoaTKThanhToan);
                commandParameters[2] = DBHelper.createParameter("@KhoaTKThueNhapKhau", DbType.Int64, ParameterDirection.Input, strKhoaTKThueNK);
                commandParameters[3] = DBHelper.createParameter("@KhoaTKNoThue", DbType.Int64, ParameterDirection.Input, strKhoaTKNoThueVAT);
                commandParameters[4] = DBHelper.createParameter("@KhoaTKCoThue", DbType.Int64, ParameterDirection.Input, strKhoaTKCoThueVAT);
                commandParameters[5] = DBHelper.createParameter("@Task", DbType.Int64, ParameterDirection.Input, "+");
                commandParameters[6] = DBHelper.createParameter("@pAmQuy", DbType.Double, ParameterDirection.Output, 0);
                commandParameters[7] = DBHelper.createParameter("@pError", DbType.Double, ParameterDirection.Output, 0);
                DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "ST_sp_GhiSoNhapKho", commandParameters);
                if (Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectNotEqual(commandParameters[7].Value, 0, false))
                {
                    if (Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectNotEqual(commandParameters[6].Value, 0, false))
                    {
                        LVYModule.ShowWarning(modGeneral.Tranlated("Nghiệp vụ kh\x00f4ng thể thực hiện được v\x00ec \x00e2m quỹ!", ""));
                    }
                    return false;
                }
                flag = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public bool Save()
        {
            bool flag=false;
            IDataParameter[] commandParameters = new IDataParameter[0x55];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@Khoa", DbType.Int64, ParameterDirection.Input, this.mKhoa);
                commandParameters[1] = DBHelper.createParameter("@KhoaLoaiNhap", DbType.Int64, ParameterDirection.Input, this.mKhoaLoaiNhap);
                commandParameters[2] = DBHelper.createParameter("@KhoaKhoanMuc", DbType.Int64, ParameterDirection.Input, this.mKhoaKhoanMuc);
                commandParameters[3] = DBHelper.createParameter("@KhoaDonHang", DbType.Int64, ParameterDirection.Input, this.mKhoaDonHang);
                commandParameters[4] = DBHelper.createParameter("@SoDonHang", DbType.Int64, ParameterDirection.Input, this.mSoDonHang);
                commandParameters[5] = DBHelper.createParameter("@NgayDonHang", DbType.Int64, ParameterDirection.Input, this.mNgayDonHang);
                commandParameters[6] = DBHelper.createParameter("@SoChungTu", DbType.Int64, ParameterDirection.Input, this.mSoChungTu);
                commandParameters[7] = DBHelper.createParameter("@NgayChungTu", DbType.Int64, ParameterDirection.Input, this.mNgayChungTu);
                commandParameters[8] = DBHelper.createParameter("@KhoaDoiTuong", DbType.Int64, ParameterDirection.Input, this.mKhoaDoiTuong);
                commandParameters[9] = DBHelper.createParameter("@KhoaNhanVien", DbType.Int64, ParameterDirection.Input, this.mKhoaNhanVien);
                commandParameters[10] = DBHelper.createParameter("@NguoiGiao", DbType.Int64, ParameterDirection.Input, this.mNguoiGiao);
                commandParameters[11] = DBHelper.createParameter("@LoaiTien", DbType.Int64, ParameterDirection.Input, this.mLoaiTien);
                commandParameters[12] = DBHelper.createParameter("@TyGia", DbType.Date, ParameterDirection.Input, this.mTyGia);
                commandParameters[13] = DBHelper.createParameter("@MaSoThue", DbType.Int64, ParameterDirection.Input, this.mMaSoThue);
                commandParameters[14] = DBHelper.createParameter("@KhoaLoaiHoaDon", DbType.Int64, ParameterDirection.Input, this.mKhoaLoaiHoaDon);
                commandParameters[15] = DBHelper.createParameter("@ThueSuat", DbType.Double, ParameterDirection.Input, this.mThueSuat);
                commandParameters[0x10] = DBHelper.createParameter("@SoHoaDon", DbType.Int64, ParameterDirection.Input, this.mSoHoaDon);
                commandParameters[0x11] = DBHelper.createParameter("@NgayHoaDon", DbType.Int64, ParameterDirection.Input, this.mNgayHoaDon);
                commandParameters[0x12] = DBHelper.createParameter("@SoSeri", DbType.Int64, ParameterDirection.Input, this.mSoSeri);
                commandParameters[0x13] = DBHelper.createParameter("@SoToKhai", DbType.Int64, ParameterDirection.Input, this.mSoToKhai);
                commandParameters[20] = DBHelper.createParameter("@NgayToKhai", DbType.Int64, ParameterDirection.Input, this.mNgayToKhai);
                commandParameters[0x15] = DBHelper.createParameter("@SoHoaDonNK", DbType.Int64, ParameterDirection.Input, this.mSoHoaDonNK);
                commandParameters[0x16] = DBHelper.createParameter("@NgayHoaDonNK", DbType.Int64, ParameterDirection.Input, this.mNgayHoaDonNK);
                commandParameters[0x17] = DBHelper.createParameter("@HanNopThueNK", DbType.Double, ParameterDirection.Input, this.mHanNopThueNK);
                commandParameters[0x18] = DBHelper.createParameter("@NgayNopThueNK", DbType.Int64, ParameterDirection.Input, this.mNgayNopThueNK);
                commandParameters[0x19] = DBHelper.createParameter("@LoaiPhanBoThueNK", DbType.Int64, ParameterDirection.Input, this.mLoaiPhanBoThueNK);
                commandParameters[0x1a] = DBHelper.createParameter("@TienHangNT", DbType.Date, ParameterDirection.Input, this.mTienHangNT);
                commandParameters[0x1b] = DBHelper.createParameter("@TienHang", DbType.Date, ParameterDirection.Input, this.mTienHang);
                commandParameters[0x1c] = DBHelper.createParameter("@TienChietKhauNT", DbType.Date, ParameterDirection.Input, this.mTienChietKhauNT);
                commandParameters[0x1d] = DBHelper.createParameter("@TienChietKhau", DbType.Date, ParameterDirection.Input, this.mTienChietKhau);
                commandParameters[30] = DBHelper.createParameter("@TienPhiNhapKhauNT", DbType.Date, ParameterDirection.Input, this.mTienPhiNhapKhauNT);
                commandParameters[0x1f] = DBHelper.createParameter("@TienPhiNhapKhau", DbType.Date, ParameterDirection.Input, this.mTienPhiNhapKhau);
                commandParameters[0x20] = DBHelper.createParameter("@TienThueNhapKhauNT", DbType.Date, ParameterDirection.Input, this.mTienThueNhapKhauNT);
                commandParameters[0x21] = DBHelper.createParameter("@TienThueNhapKhau", DbType.Date, ParameterDirection.Input, this.mTienThueNhapKhau);
                commandParameters[0x22] = DBHelper.createParameter("@TienThueVATNT", DbType.Date, ParameterDirection.Input, this.mTienThueVATNT);
                commandParameters[0x23] = DBHelper.createParameter("@TienThueVAT", DbType.Date, ParameterDirection.Input, this.mTienThueVAT);
                commandParameters[0x24] = DBHelper.createParameter("@TienPhiNT", DbType.Date, ParameterDirection.Input, this.mTienPhiNT);
                commandParameters[0x25] = DBHelper.createParameter("@TienPhi", DbType.Date, ParameterDirection.Input, this.mTienPhi);
                commandParameters[0x26] = DBHelper.createParameter("@KhoaTKThanhToan", DbType.Int64, ParameterDirection.Input, this.mKhoaTKThanhToan);
                commandParameters[0x27] = DBHelper.createParameter("@KhoaTKThueNK", DbType.Int64, ParameterDirection.Input, this.mKhoaTKThueNK);
                commandParameters[40] = DBHelper.createParameter("@KhoaTKNoThueVAT", DbType.Int64, ParameterDirection.Input, this.mKhoaTKNoThueVAT);
                commandParameters[0x29] = DBHelper.createParameter("@KhoaTKCoThueVAT", DbType.Int64, ParameterDirection.Input, this.mKhoaTKCoThueVAT);
                commandParameters[0x2a] = DBHelper.createParameter("@NguonNhap", DbType.Int64, ParameterDirection.Input, this.mNguonNhap);
                commandParameters[0x2b] = DBHelper.createParameter("@DienGiai", DbType.Int64, ParameterDirection.Input, this.mDienGiai);
                commandParameters[0x2c] = DBHelper.createParameter("@HanThanhToan", DbType.Double, ParameterDirection.Input, this.mHanThanhToan);
                commandParameters[0x2d] = DBHelper.createParameter("@NgayThanhToan", DbType.Int64, ParameterDirection.Input, this.mNgayThanhToan);
                commandParameters[0x2e] = DBHelper.createParameter("@DaThanhToanNT", DbType.Date, ParameterDirection.Input, this.mDaThanhToanNT);
                commandParameters[0x2f] = DBHelper.createParameter("@DaThanhToan", DbType.Date, ParameterDirection.Input, this.mDaThanhToan);
                commandParameters[0x30] = DBHelper.createParameter("@KhoaNhanVienTao", DbType.Int64, ParameterDirection.Input, this.mKhoaNhanVienTao);
                commandParameters[0x31] = DBHelper.createParameter("@NgayTao", DbType.Int64, ParameterDirection.Input, this.mNgayTao);
                commandParameters[50] = DBHelper.createParameter("@KhoaNhanVienSua", DbType.Int64, ParameterDirection.Input, this.mKhoaNhanVienSua);
                commandParameters[0x33] = DBHelper.createParameter("@NgaySua", DbType.Int64, ParameterDirection.Input, this.mNgaySua);
                commandParameters[0x34] = DBHelper.createParameter("@GhiSo", DbType.Double, ParameterDirection.Input, this.mGhiSo);
                commandParameters[0x35] = DBHelper.createParameter("@KhoaDonVi", DbType.Int64, ParameterDirection.Input, this.mKhoaDonVi);
                commandParameters[0x36] = DBHelper.createParameter("@Send", DbType.Double, ParameterDirection.Input, this.mSend);
                commandParameters[0x37] = DBHelper.createParameter("@KhoaBoPhan", DbType.Int64, ParameterDirection.Input, this.mKhoaBoPhan);
                commandParameters[0x38] = DBHelper.createParameter("@KhoaSanPham", DbType.Int64, ParameterDirection.Input, this.mKhoaSanPham);
                commandParameters[0x39] = DBHelper.createParameter("@KhoaHopDong", DbType.Int64, ParameterDirection.Input, this.mKhoaHopDong);
                commandParameters[0x3a] = DBHelper.createParameter("@SoHopDong", DbType.Int64, ParameterDirection.Input, this.mSoHopDong);
                commandParameters[0x3b] = DBHelper.createParameter("@DaNopThueNK", DbType.Date, ParameterDirection.Input, this.mDaNopThueNK);
                commandParameters[60] = DBHelper.createParameter("@DaNopThue", DbType.Date, ParameterDirection.Input, this.mDaNopThue);
                commandParameters[0x3d] = DBHelper.createParameter("@TienPhiNhap", DbType.Date, ParameterDirection.Input, this.mTienPhiNhap);
                commandParameters[0x3e] = DBHelper.createParameter("@TienThuePhiNhap", DbType.Date, ParameterDirection.Input, this.mTienThuePhiNhap);
                commandParameters[0x3f] = DBHelper.createParameter("@KhoaTKCoPhiNK", DbType.Int64, ParameterDirection.Input, this.mKhoaTKCoPhiNK);
                commandParameters[0x40] = DBHelper.createParameter("@KhoaTKThuePhiNK", DbType.Int64, ParameterDirection.Input, this.mKhoaTKThuePhiNK);
                commandParameters[0x41] = DBHelper.createParameter("@KhoaDoiTuongPhiNK", DbType.Int64, ParameterDirection.Input, this.mKhoaDoiTuongPhiNK);
                commandParameters[0x42] = DBHelper.createParameter("@LoaiTienPhiNK", DbType.Int64, ParameterDirection.Input, this.mLoaiTienPhiNK);
                commandParameters[0x43] = DBHelper.createParameter("@TyGiaPhiNK", DbType.Date, ParameterDirection.Input, this.mTyGiaPhiNK);
                commandParameters[0x44] = DBHelper.createParameter("@PhanBoPhiNK", DbType.Int64, ParameterDirection.Input, this.mPhanBoPhiNK);
                commandParameters[0x45] = DBHelper.createParameter("@KhoaLoaiHoaDonNK", DbType.Int64, ParameterDirection.Input, this.mKhoaLoaiHoaDonNK);
                commandParameters[70] = DBHelper.createParameter("@SoHoaDonPhiNK", DbType.Int64, ParameterDirection.Input, this.mSoHoaDonPhiNK);
                commandParameters[0x47] = DBHelper.createParameter("@NgayHoaDonPhiNK", DbType.Int64, ParameterDirection.Input, this.mNgayHoaDonPhiNK);
                commandParameters[0x48] = DBHelper.createParameter("@SoSeriPhiNK", DbType.Int64, ParameterDirection.Input, this.mSoSeriPhiNK);
                commandParameters[0x49] = DBHelper.createParameter("@ThueSuatPhiNK", DbType.Double, ParameterDirection.Input, this.mThueSuatPhiNK);
                commandParameters[0x4a] = DBHelper.createParameter("@TienPhiNKNT", DbType.Date, ParameterDirection.Input, this.mTienPhiNKNT);
                commandParameters[0x4b] = DBHelper.createParameter("@TienPhiNK", DbType.Date, ParameterDirection.Input, this.mTienPhiNK);
                commandParameters[0x4c] = DBHelper.createParameter("@TienThuePhiNKNT", DbType.Date, ParameterDirection.Input, this.mTienThuePhiNKNT);
                commandParameters[0x4d] = DBHelper.createParameter("@TienThuePhiNK", DbType.Date, ParameterDirection.Input, this.mTienThuePhiNK);
                commandParameters[0x4e] = DBHelper.createParameter("@DienGiaiPhiNK", DbType.Int64, ParameterDirection.Input, this.mDienGiaiPhiNK);
                commandParameters[0x4f] = DBHelper.createParameter("@DuLieu", DbType.Int64, ParameterDirection.Input, this.mDuLieu);
                commandParameters[80] = DBHelper.createParameter("@Duyet", DbType.Double, ParameterDirection.Input, this.mDuyet);
                commandParameters[0x51] = DBHelper.createParameter("@KhoaHangMucBaoCaoThue", DbType.Int64, ParameterDirection.Input, this.mKhoaHangMucBaoCaoThue);
                commandParameters[0x52] = DBHelper.createParameter("@AmQuy", DbType.Double, ParameterDirection.Output, 0);
                commandParameters[0x53] = DBHelper.createParameter("@AmKho", DbType.Double, ParameterDirection.Output, 0);
                commandParameters[0x54] = DBHelper.createParameter("@pError", DbType.Double, ParameterDirection.Output, 0);
                int num = DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "ST_sp_NhapKho", commandParameters);
                if (Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectEqual(commandParameters[0x54].Value, 0, false))
                {
                    return true;
                }
                if (Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectNotEqual(commandParameters[0x52].Value, 0, false))
                {
                    LVYModule.ShowWarning(modGeneral.Tranlated("Nghiệp vụ kh\x00f4ng thể thực hiện được v\x00ec \x00e2m quỹ!", ""));
                }
                if (Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectNotEqual(commandParameters[0x53].Value, 0, false))
                {
                    LVYModule.ShowWarning(modGeneral.Tranlated("Nghiệp vụ kh\x00f4ng thể thực hiện được v\x00ec \x00e2m kho!", ""));
                }
                flag = false;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public void SetBlank()
        {
            this.mKhoa = "";
            this.mKhoaLoaiNhap = "";
            this.mKhoaKhoanMuc = "";
            this.mKhoaDonHang = "";
            this.mSoDonHang = "";
            this.mNgayDonHang = "";
            this.mSoChungTu = "";
            this.mNgayChungTu = "";
            this.mKhoaDoiTuong = "";
            this.mNguoiGiao = "";
            this.mLoaiTien = "";
            this.mTyGia = 0.0;
            this.mMaSoThue = "";
            this.mKhoaLoaiHoaDon = "";
            this.mThueSuat = 0;
            this.mSoHoaDon = "";
            this.mNgayHoaDon = "";
            this.mSoSeri = "";
            this.mSoToKhai = "";
            this.mNgayToKhai = "";
            this.mSoHoaDonNK = "";
            this.mNgayHoaDonNK = "";
            this.mHanNopThueNK = 0;
            this.mNgayNopThueNK = "";
            this.mLoaiPhanBoThueNK = "";
            this.mTienHangNT = 0.0;
            this.mTienHang = 0.0;
            this.mTienChietKhauNT = 0.0;
            this.mTienChietKhau = 0.0;
            this.mTienPhiNhapKhauNT = 0.0;
            this.mTienPhiNhapKhau = 0.0;
            this.mTienThueNhapKhauNT = 0.0;
            this.mTienThueNhapKhau = 0.0;
            this.mTienThueVATNT = 0.0;
            this.mTienThueVAT = 0.0;
            this.mTienPhiNT = 0.0;
            this.mTienPhi = 0.0;
            this.mKhoaTKThanhToan = "";
            this.mKhoaTKThueNK = "";
            this.mKhoaTKNoThueVAT = "";
            this.mKhoaTKCoThueVAT = "";
            this.mNguonNhap = "";
            this.mDienGiai = "";
            this.mHanThanhToan = 0;
            this.mNgayThanhToan = "";
            this.mDaThanhToanNT = 0.0;
            this.mDaThanhToan = 0.0;
            this.mKhoaNhanVienTao = "";
            this.mNgayTao = "";
            this.mKhoaNhanVienSua = "";
            this.mNgaySua = "";
            this.mGhiSo = 0;
            this.mKhoaDonVi = "";
            this.mSend = 0;
            this.mKhoaBoPhan = "";
            this.mKhoaSanPham = "";
            this.mKhoaHopDong = "";
            this.mSoHopDong = "";
            this.mDaNopThue = 0.0;
            this.mTienPhiNhap = 0.0;
            this.mTienThuePhiNhap = 0.0;
        }

        public DataTable ShowListByField(string strFieldList, string pSQL = "")
        {
            IDataParameter parameter = null;
            DataTable table;
            strFieldList = Strings.Replace(strFieldList, "|", ",", 1, -1, CompareMethod.Binary);
            try
            {
                pSQL = " SELECT " + strFieldList + " ,NK.SoChungTu,NK.NgayChungTu,DT.TenViet as NhaCungCap, NK.SoTokhai, NK.SoHoaDonNK, NK.TienHangNT, NK.TienThueNhapKhauNT FROM ST_NhapKho NK left join DM_DoiTuong DT on NK.KhoaDoiTuong = DT.Khoa  Where  (NK.TienThueNhapKhauNT > 0) And (NK.TienThueNhapKhauNT - isnull(NK.DaNopThueNK,0))> 0 ";
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, pSQL, new IDataParameter[] { parameter }).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public bool UnRegistered(string strKhoa)
        {
            bool flag=false;
            IDataParameter[] commandParameters = new IDataParameter[8];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@KhoaPhieuNhap", DbType.Int64, ParameterDirection.Input, strKhoa);
                commandParameters[1] = DBHelper.createParameter("@KhoaTKThanhToan", DbType.Int64, ParameterDirection.Input, "");
                commandParameters[2] = DBHelper.createParameter("@KhoaTKThueNhapKhau", DbType.Int64, ParameterDirection.Input, "");
                commandParameters[3] = DBHelper.createParameter("@KhoaTKNoThue", DbType.Int64, ParameterDirection.Input, "");
                commandParameters[4] = DBHelper.createParameter("@KhoaTKCoThue", DbType.Int64, ParameterDirection.Input, "");
                commandParameters[5] = DBHelper.createParameter("@Task", DbType.Int64, ParameterDirection.Input, "-");
                commandParameters[6] = DBHelper.createParameter("@pAmQuy", DbType.Double, ParameterDirection.Output, 0);
                commandParameters[7] = DBHelper.createParameter("@pError", DbType.Double, ParameterDirection.Output, 0);
                int num = DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "ST_sp_GhiSoNhapKho", commandParameters);
                if (Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectNotEqual(commandParameters[7].Value, 0, false))
                {
                    if (Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectNotEqual(commandParameters[6].Value, 0, false))
                    {
                        LVYModule.ShowWarning(modGeneral.Tranlated("Nghiệp vụ kh\x00f4ng thể thực hiện được v\x00ec \x00e2m quỹ!", ""));
                    }
                    return false;
                }
                flag = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public bool WasUsed(string pKhoa)
        {
            bool flag2;
            string commandText = "";
            IDataParameter parameter = null;
            try
            {
                commandText = "SELECT * FROM ST_XuatKho WHERE RTRIM(KhoaDonHang) = '" + pKhoa.Trim() + "'";
                bool flag = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[] { parameter }).Tables[0].Rows.Count > 0;
                flag2 = flag;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                flag2 = true;
                ProjectData.ClearProjectError();
                return flag2;
                ProjectData.ClearProjectError();
            }
            return flag2;
        }

        public double DaNopThue
        {
            get
            {
                return this.mDaNopThue;
            }
            set
            {
                this.mDaNopThue = value;
            }
        }

        public double DaNopThueNK
        {
            get
            {
                return this.mDaNopThueNK;
            }
            set
            {
                this.mDaNopThueNK = value;
            }
        }

        public double DaThanhToan
        {
            get
            {
                return this.mDaThanhToan;
            }
            set
            {
                this.mDaThanhToan = value;
            }
        }

        public double DaThanhToanNT
        {
            get
            {
                return this.mDaThanhToanNT;
            }
            set
            {
                this.mDaThanhToanNT = value;
            }
        }

        public string DienGiai
        {
            get
            {
                return this.mDienGiai;
            }
            set
            {
                this.mDienGiai = value;
            }
        }

        public string DienGiaiPhiNK
        {
            get
            {
                return this.mDienGiaiPhiNK;
            }
            set
            {
                this.mDienGiaiPhiNK = value;
            }
        }

        public string DuLieu
        {
            get
            {
                return this.mDuLieu;
            }
            set
            {
                this.mDuLieu = value;
            }
        }

        public int Duyet
        {
            get
            {
                return this.mDuyet;
            }
            set
            {
                this.mDuyet = value;
            }
        }

        public int GhiSo
        {
            get
            {
                return this.mGhiSo;
            }
            set
            {
                this.mGhiSo = value;
            }
        }

        public int HanNopThueNK
        {
            get
            {
                return this.mHanNopThueNK;
            }
            set
            {
                this.mHanNopThueNK = value;
            }
        }

        public int HanThanhToan
        {
            get
            {
                return this.mHanThanhToan;
            }
            set
            {
                this.mHanThanhToan = value;
            }
        }

        public string Khoa
        {
            get
            {
                return this.mKhoa;
            }
            set
            {
                this.mKhoa = value;
            }
        }

        public string KhoaBoPhan
        {
            get
            {
                return this.mKhoaBoPhan;
            }
            set
            {
                this.mKhoaBoPhan = value;
            }
        }

        public string KhoaDoiTuong
        {
            get
            {
                return this.mKhoaDoiTuong;
            }
            set
            {
                this.mKhoaDoiTuong = value;
            }
        }

        public string KhoaDoiTuongPhiNK
        {
            get
            {
                return this.mKhoaDoiTuongPhiNK;
            }
            set
            {
                this.mKhoaDoiTuongPhiNK = value;
            }
        }

        public string KhoaDonHang
        {
            get
            {
                return this.mKhoaDonHang;
            }
            set
            {
                this.mKhoaDonHang = value;
            }
        }

        public string KhoaDonVi
        {
            get
            {
                return this.mKhoaDonVi;
            }
            set
            {
                this.mKhoaDonVi = value;
            }
        }

        public string KhoaHangMucBaoCaoThue
        {
            get
            {
                return this.mKhoaHangMucBaoCaoThue;
            }
            set
            {
                this.mKhoaHangMucBaoCaoThue = value;
            }
        }

        public string KhoaHopDong
        {
            get
            {
                return this.mKhoaHopDong;
            }
            set
            {
                this.mKhoaHopDong = value;
            }
        }

        public string KhoaKhoanMuc
        {
            get
            {
                return this.mKhoaKhoanMuc;
            }
            set
            {
                this.mKhoaKhoanMuc = value;
            }
        }

        public string KhoaLoaiHoaDon
        {
            get
            {
                return this.mKhoaLoaiHoaDon;
            }
            set
            {
                this.mKhoaLoaiHoaDon = value;
            }
        }

        public string KhoaLoaiHoaDonNK
        {
            get
            {
                return this.mKhoaLoaiHoaDonNK;
            }
            set
            {
                this.mKhoaLoaiHoaDonNK = value;
            }
        }

        public string KhoaLoaiNhap
        {
            get
            {
                return this.mKhoaLoaiNhap;
            }
            set
            {
                this.mKhoaLoaiNhap = value;
            }
        }

        public string KhoaNhanVien
        {
            get
            {
                return this.mKhoaNhanVien;
            }
            set
            {
                this.mKhoaNhanVien = value;
            }
        }

        public string KhoaNhanVienSua
        {
            get
            {
                return this.mKhoaNhanVienSua;
            }
            set
            {
                this.mKhoaNhanVienSua = value;
            }
        }

        public string KhoaNhanVienTao
        {
            get
            {
                return this.mKhoaNhanVienTao;
            }
            set
            {
                this.mKhoaNhanVienTao = value;
            }
        }

        public string KhoaSanPham
        {
            get
            {
                return this.mKhoaSanPham;
            }
            set
            {
                this.mKhoaSanPham = value;
            }
        }

        public string KhoaTKCoPhiNK
        {
            get
            {
                return this.mKhoaTKCoPhiNK;
            }
            set
            {
                this.mKhoaTKCoPhiNK = value;
            }
        }

        public string KhoaTKCoThueVAT
        {
            get
            {
                return this.mKhoaTKCoThueVAT;
            }
            set
            {
                this.mKhoaTKCoThueVAT = value;
            }
        }

        public string KhoaTKNoThueVAT
        {
            get
            {
                return this.mKhoaTKNoThueVAT;
            }
            set
            {
                this.mKhoaTKNoThueVAT = value;
            }
        }

        public string KhoaTKThanhToan
        {
            get
            {
                return this.mKhoaTKThanhToan;
            }
            set
            {
                this.mKhoaTKThanhToan = value;
            }
        }

        public string KhoaTKThueNK
        {
            get
            {
                return this.mKhoaTKThueNK;
            }
            set
            {
                this.mKhoaTKThueNK = value;
            }
        }

        public string KhoaTKThuePhiNK
        {
            get
            {
                return this.mKhoaTKThuePhiNK;
            }
            set
            {
                this.mKhoaTKThuePhiNK = value;
            }
        }

        public string LoaiPhanBoThueNK
        {
            get
            {
                return this.mLoaiPhanBoThueNK;
            }
            set
            {
                this.mLoaiPhanBoThueNK = value;
            }
        }

        public string LoaiTien
        {
            get
            {
                return this.mLoaiTien;
            }
            set
            {
                this.mLoaiTien = value;
            }
        }

        public string LoaiTienPhiNK
        {
            get
            {
                return this.mLoaiTienPhiNK;
            }
            set
            {
                this.mLoaiTienPhiNK = value;
            }
        }

        public string MaSoThue
        {
            get
            {
                return this.mMaSoThue;
            }
            set
            {
                this.mMaSoThue = value;
            }
        }

        public string NgayChungTu
        {
            get
            {
                return this.mNgayChungTu;
            }
            set
            {
                this.mNgayChungTu = value;
            }
        }

        public string NgayDonHang
        {
            get
            {
                return this.mNgayDonHang;
            }
            set
            {
                this.mNgayDonHang = value;
            }
        }

        public string NgayHoaDon
        {
            get
            {
                return this.mNgayHoaDon;
            }
            set
            {
                this.mNgayHoaDon = value;
            }
        }

        public string NgayHoaDonNK
        {
            get
            {
                return this.mNgayHoaDonNK;
            }
            set
            {
                this.mNgayHoaDonNK = value;
            }
        }

        public string NgayHoaDonPhiNK
        {
            get
            {
                return this.mNgayHoaDonPhiNK;
            }
            set
            {
                this.mNgayHoaDonPhiNK = value;
            }
        }

        public string NgayNopThueNK
        {
            get
            {
                return this.mNgayNopThueNK;
            }
            set
            {
                this.mNgayNopThueNK = value;
            }
        }

        public string NgaySua
        {
            get
            {
                return this.mNgaySua;
            }
            set
            {
                this.mNgaySua = value;
            }
        }

        public string NgayTao
        {
            get
            {
                return this.mNgayTao;
            }
            set
            {
                this.mNgayTao = value;
            }
        }

        public string NgayThanhToan
        {
            get
            {
                return this.mNgayThanhToan;
            }
            set
            {
                this.mNgayThanhToan = value;
            }
        }

        public string NgayToKhai
        {
            get
            {
                return this.mNgayToKhai;
            }
            set
            {
                this.mNgayToKhai = value;
            }
        }

        public string NguoiGiao
        {
            get
            {
                return this.mNguoiGiao;
            }
            set
            {
                this.mNguoiGiao = value;
            }
        }

        public string NguonNhap
        {
            get
            {
                return this.mNguonNhap;
            }
            set
            {
                this.mNguonNhap = value;
            }
        }

        public string PhanBoPhiNK
        {
            get
            {
                return this.mPhanBoPhiNK;
            }
            set
            {
                this.mPhanBoPhiNK = value;
            }
        }

        public int Send
        {
            get
            {
                return this.mSend;
            }
            set
            {
                this.mSend = value;
            }
        }

        public string SoChungTu
        {
            get
            {
                return this.mSoChungTu;
            }
            set
            {
                this.mSoChungTu = value;
            }
        }

        public string SoDonHang
        {
            get
            {
                return this.mSoDonHang;
            }
            set
            {
                this.mSoDonHang = value;
            }
        }

        public string SoHoaDon
        {
            get
            {
                return this.mSoHoaDon;
            }
            set
            {
                this.mSoHoaDon = value;
            }
        }

        public string SoHoaDonNK
        {
            get
            {
                return this.mSoHoaDonNK;
            }
            set
            {
                this.mSoHoaDonNK = value;
            }
        }

        public string SoHoaDonPhiNK
        {
            get
            {
                return this.mSoHoaDonPhiNK;
            }
            set
            {
                this.mSoHoaDonPhiNK = value;
            }
        }

        public string SoHopDong
        {
            get
            {
                return this.mSoHopDong;
            }
            set
            {
                this.mSoHopDong = value;
            }
        }

        public string SoSeri
        {
            get
            {
                return this.mSoSeri;
            }
            set
            {
                this.mSoSeri = value;
            }
        }

        public string SoSeriPhiNK
        {
            get
            {
                return this.mSoSeriPhiNK;
            }
            set
            {
                this.mSoSeriPhiNK = value;
            }
        }

        public string SoToKhai
        {
            get
            {
                return this.mSoToKhai;
            }
            set
            {
                this.mSoToKhai = value;
            }
        }

        public int ThueSuat
        {
            get
            {
                return this.mThueSuat;
            }
            set
            {
                this.mThueSuat = value;
            }
        }

        public int ThueSuatPhiNK
        {
            get
            {
                return this.mThueSuatPhiNK;
            }
            set
            {
                this.mThueSuatPhiNK = value;
            }
        }

        public double TienChietKhau
        {
            get
            {
                return this.mTienChietKhau;
            }
            set
            {
                this.mTienChietKhau = value;
            }
        }

        public double TienChietKhauNT
        {
            get
            {
                return this.mTienChietKhauNT;
            }
            set
            {
                this.mTienChietKhauNT = value;
            }
        }

        public double TienHang
        {
            get
            {
                return this.mTienHang;
            }
            set
            {
                this.mTienHang = value;
            }
        }

        public double TienHangNT
        {
            get
            {
                return this.mTienHangNT;
            }
            set
            {
                this.mTienHangNT = value;
            }
        }

        public double TienPhi
        {
            get
            {
                return this.mTienPhi;
            }
            set
            {
                this.mTienPhi = value;
            }
        }

        public double TienPhiNhap
        {
            get
            {
                return this.mTienPhiNhap;
            }
            set
            {
                this.mTienPhiNhap = value;
            }
        }

        public double TienPhiNhapKhau
        {
            get
            {
                return this.mTienPhiNhapKhau;
            }
            set
            {
                this.mTienPhiNhapKhau = value;
            }
        }

        public double TienPhiNhapKhauNT
        {
            get
            {
                return this.mTienPhiNhapKhauNT;
            }
            set
            {
                this.mTienPhiNhapKhauNT = value;
            }
        }

        public double TienPhiNK
        {
            get
            {
                return this.mTienPhiNK;
            }
            set
            {
                this.mTienPhiNK = value;
            }
        }

        public double TienPhiNKNT
        {
            get
            {
                return this.mTienPhiNKNT;
            }
            set
            {
                this.mTienPhiNKNT = value;
            }
        }

        public double TienPhiNT
        {
            get
            {
                return this.mTienPhiNT;
            }
            set
            {
                this.mTienPhiNT = value;
            }
        }

        public double TienThueNhapKhau
        {
            get
            {
                return this.mTienThueNhapKhau;
            }
            set
            {
                this.mTienThueNhapKhau = value;
            }
        }

        public double TienThueNhapKhauNT
        {
            get
            {
                return this.mTienThueNhapKhauNT;
            }
            set
            {
                this.mTienThueNhapKhauNT = value;
            }
        }

        public double TienThuePhiNhap
        {
            get
            {
                return this.mTienThuePhiNhap;
            }
            set
            {
                this.mTienThuePhiNhap = value;
            }
        }

        public double TienThuePhiNK
        {
            get
            {
                return this.mTienThuePhiNK;
            }
            set
            {
                this.mTienThuePhiNK = value;
            }
        }

        public double TienThuePhiNKNT
        {
            get
            {
                return this.mTienThuePhiNKNT;
            }
            set
            {
                this.mTienThuePhiNKNT = value;
            }
        }

        public double TienThueVAT
        {
            get
            {
                return this.mTienThueVAT;
            }
            set
            {
                this.mTienThueVAT = value;
            }
        }

        public double TienThueVATNT
        {
            get
            {
                return this.mTienThueVATNT;
            }
            set
            {
                this.mTienThueVATNT = value;
            }
        }

        public double TyGia
        {
            get
            {
                return this.mTyGia;
            }
            set
            {
                this.mTyGia = value;
            }
        }

        public double TyGiaPhiNK
        {
            get
            {
                return this.mTyGiaPhiNK;
            }
            set
            {
                this.mTyGiaPhiNK = value;
            }
        }
    }
}

